/*
    Copyright (C) 2009 Giacomo Spigler

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License along
    with this program; if not, write to the Free Software Foundation, Inc.,
    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#ifndef __STANDARD__H__
#define __STANDARD__H__


#include <cv.h>


extern "C" {
//#define DEBUG


#define S1BLOCKS 64
#define S1THREADS 128

#define C1BLOCKS 64
#define C1THREADS 128

// n4, n8 multiples of S2THREADS
#define S2BLOCKS 256
#define S2THREADS 128

// nums2 multiple of C2BLOCKS
#define C2BLOCKS 256
#define C2THREADS 128




#define SCALERATIO 0.83
#define INVERSESCALERATIO 1.2

#define NUMSCALES 10

#define C1_STEP 5
#define C1_SIZE 10
#define C1_SIZE2 8


void InitWidthsHeights(int w_host[NUMSCALES], int h_host[NUMSCALES], int **w_dev, int **h_dev);
void LoadS2Patches(const char *file, int *nums2, int *n4, int *n8, unsigned char **patch4x4, unsigned char **patch8x8);
void InitPyramidBuffer(IplImage *pyr[NUMSCALES], unsigned char **pyr_dev, unsigned char *s1_dev[4], unsigned char *c1_dev[4], size_t *pitch, size_t *c1_pitch, unsigned char **s2_dev, int nums2, size_t *s2_pitch, unsigned char **c2_dev, unsigned char **c2_host);
void FreeAll(int *w_dev, int *h_dev, unsigned char *pyr_dev, unsigned char *s1_dev[4], unsigned char *c1_dev[4], unsigned char *patch4x4, unsigned char *patch8x8, unsigned char *s2_dev, unsigned char *c2_dev, unsigned char *c2_host);


void SetPyramid_0(IplImage *im, IplImage *pyr[NUMSCALES], unsigned char *pyr_dev, size_t pyr_dev_pitch);
void ComputeS1_1(unsigned char *pyr_dev, unsigned char *s1_dev[4], int w_host[NUMSCALES], int h_host[NUMSCALES], int *w_dev, int *h_dev, size_t pyr_dev_pitch,   IplImage *pyr[NUMSCALES]);
void ComputeC1_2(unsigned char *s1_dev[4], unsigned char *c1_dev[4], int w_host[NUMSCALES], int h_host[NUMSCALES], int *w_dev, int *h_dev, size_t pyr_dev_pitch, size_t c1_pitch,  IplImage *pyr[NUMSCALES]);
void ComputeS2_3(unsigned char *c1_dev[4], int w_host[NUMSCALES], int h_host[NUMSCALES], int *w_dev, int *h_dev, size_t c1_pitch, size_t s2_pitch, unsigned char *s2_dev, int nums2, int n4, int n8, unsigned char *patch4x4, unsigned char *patch8x8,   IplImage *pyr[NUMSCALES]);
void ComputeC2_4(int w_host[NUMSCALES], int h_host[NUMSCALES], int *w_dev, int *h_dev, size_t s2_pitch, unsigned char *s2_dev, int nums2, unsigned char *c2_dev, unsigned char *c2_host,   IplImage *pyr[NUMSCALES]);











}




#endif /* __STANDARD__H__ */


